import HttpUtils from '../../common/utils/HttpUtils'
import CommonUtils from '../../common/utils/CommonUtils'



export default class ProductIntro extends React.Component{
    constructor(){
        super()
        this.state={
            brands:[

            ],
            supplier:{}
        }
    }

    componentDidMount() {
        this.getSupplierInfo()

    }


    getSupplierInfo(){
        const {suppId,product}=this.props
        HttpUtils.getSupplierInfo(product.brandId,suppId)
            .then(res=>{
                console.log(res)
                this.setState({
                    supplier:res.supplier
                })
            })
            .catch(err=>{
                console.log(err)
            })
    }

    render(){
        const {supplier}=this.state
        const {product}=this.props
        const {brandName,name,productNum,casNo,suppname,desc,brand,exAttributes}=product //

        if(!exAttributes){
           return (
               <div
                   dangerouslySetInnerHTML={{__html:desc}}
                   className={'detail-product-info-intro'}>
               </div>
           )
        }
        if(exAttributes&&exAttributes.length==0){
            return (
                <div
                    dangerouslySetInnerHTML={{__html:desc}}
                    className={'detail-product-info-intro'}>
                </div>
            )
        }

        return(
            <div>
                <div  className={'detail-center-header-jianjie'}>
                    <div className={'detail-center-header-layer1'}>
                        {
                            exAttributes&&exAttributes.map((item,index)=>{
                                const {attrName,attrValue}=item
                                return(
                                    <div className={(index+1)%3==0 ?'detail-product-intro-item3':'detail-product-intro-item1'} key={index} >
                                        <span className={'detail-product-intro-item-title'}>{attrName}</span>
                                        <span className={'detail-product-intro-item-p'}>{
                                            Filter.cutString(attrValue,30,1)
                                        }</span>
                                    </div>
                                    )
                            })
                        }
                    </div>
                </div>
                <div
                    dangerouslySetInnerHTML={{__html:desc}}
                    className={'detail-product-info-intro'}>
                </div>
            </div>

        )
    }
}


{/*<div className={'detail-product-intro-item1'}>*/}
    {/*<p className={'detail-product-intro-item-title'}>{'名称'}</p>*/}
    {/*<p className={'detail-product-intro-item-p'}>{name}</p>*/}
{/*</div>*/}
{/*<div className={'detail-product-intro-item1'}>*/}
    {/*<p className={'detail-product-intro-item-title'}>{'编号'}</p>*/}
{/*<p className={'detail-product-intro-item-p'}>{productNum}</p>*/}
{/*</div>*/}

{/*<div className={'detail-center-header-layer2'}>*/}
    {/*{*/}
        {/*casNo&&*/}
        {/*<div className={'detail-product-intro-item2'}>*/}
            {/*<p className={'detail-product-intro-item-title2'}>{'CAS号'}</p>*/}
            {/*<p className={'detail-product-intro-item-p'}>{casNo}</p>*/}
        {/*</div>*/}
    {/*}*/}

    {/*<div className={'detail-product-intro-item2'}>*/}
        {/*<p className={'detail-product-intro-item-title2'}>{'供应商'}</p>*/}
        {/*<p className={'detail-product-intro-item-p'}>{suppname||supplier.name}</p>*/}
    {/*</div>*/}
{/*</div>*/}
{/*<AttartComp*/}
{/*exAttributes={exAttributes}*/}
{/*/>*/}


